package com.tjsinfo.tjsoa.documentationflow.dangweishouwen.action;

import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.common.ToolKit;
import com.tjsinfo.tjsoa.documentationflow.dangweishouwen.bo.ITDangweishouwenNeirongBO;
import com.tjsinfo.tjsoa.system.bo.ISystemUserBo;
import com.tjsinfo.tjsoa.system.vo.TSystemUser;

public class WuLinChengDengJiFromAction extends Action{
	private ISystemUserBo systemUserBo;
	private ITDangweishouwenNeirongBO dangweishouwenNeirongBO;
	public ITDangweishouwenNeirongBO getDangweishouwenNeirongBO() {
		return dangweishouwenNeirongBO;
	}
	public void setDangweishouwenNeirongBO(
			ITDangweishouwenNeirongBO dangweishouwenNeirongBO) {
		this.dangweishouwenNeirongBO = dangweishouwenNeirongBO;
	}
	public ISystemUserBo getSystemUserBo() {
		return systemUserBo;
	}
	public void setSystemUserBo(ISystemUserBo systemUserBo) {
		this.systemUserBo = systemUserBo;
	}
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		String qingban = ToolKit.getProperties("com/tjsinfo/tjsoa/documentationflow/dangweishouwen/properties/systemResource_zh_CN.properties", this).getProperty("dangweishouwen.qingban");
		List<TSystemUser> systemuserlist = systemUserBo.selectByDutyName(qingban);
		if (systemuserlist != null &&systemuserlist.size() > 0) {
			TSystemUser systemUser = systemuserlist.get(0);
			request.setAttribute("qingbanname", systemUser.getUserName());
			request.setAttribute("qingbanid", systemUser.getUserId());
		
		} else {
			request.setAttribute("qingbanname", "admin");
			request.setAttribute("qingbanid", 1);
		}
		Integer zongshouwenbianhao = dangweishouwenNeirongBO.selectMaxZongShouWenHaoByYear();
		if(zongshouwenbianhao==0)
		{
			zongshouwenbianhao=1;
		}
		if(zongshouwenbianhao != 1){
			request.setAttribute("zongshouwenbianhao", (new Date().getYear()+ 1900)+zongshouwenbianhao.toString().substring(4));
		}else{
			request.setAttribute("zongshouwenbianhao", (new Date().getYear()+ 1900)+"0001");
		}
		return mapping.findForward("ok");
	}
	
}

